<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>自定义过滤器</title>
</head>
<body>
<div id="myapp">

  <!-- in mustaches -->
  {{ message | capitalize }}
  <!-- in v-bind -->
  <div v-bind:id="rawId | formatId">{{rawId | formatId}}</div>
</div>
<script src="//cdn.bootcss.com/vue/2.2.1/vue.js"></script>
<script>
  new Vue({
    el: "#myapp",
    data: {rawId: "testabcd", message: "what are you doing?天街小雨润如酥"},
    filters: {

      formatId: function (value) {
        return value.toUpperCase()
      },
      capitalize: function (value) {
        if (!value) return ''
        value = value.toString()
        return value.charAt(0).toUpperCase() + value.slice(1)
      }
    }
  })
</script>
</body>
</html>
